<?php

namespace App\Logic;

use App\Models\Administrator;
use App\Models\House;

class HouseLogic
{


    /**
     * @name  wl
     * @function 房屋展示
     * @return House[]|\Illuminate\Database\Eloquent\Collection
     */
    public static function HouseShow()
    {
        return House::showList();
    }

    /**
     *
     * @param $id
     * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
     */
    public static function houseDeaTeLogic($id)
    {

        $sql = House::houseDeaTe( $id);
        return $sql;
    }

    /**
     * @function 删除数据
     * @param $id
     * @return mixed
     */
    public static function del($id)
    {
        if (empty($id)) throw new \RuntimeException('参数为空');
        $houseDel = House::del('id', $id);
        return $houseDel;
    }

    /**
     * @function  搜索方法
     * @param $data
     * @return Administrator[]|\Illuminate\Database\Eloquent\Collection
     */
    public static function searchFunction($data)
    {
        if (empty($message)) {
            return Administrator::showList();
        }
        $houseSearch = House::search('username', $data);
        return $houseSearch;
    }


    /**
     * @function 修改方法
     * @param $data
     * @return mixed
     */
    public static function HouseUpdate($data)
    {
        $HouseSql = House::upDatHouse('id', $data);
        return $HouseSql;
    }


    /**
     * @function 看房时间
     */
    public function openHome($startTime)
    {
        if (empty($startTime)) {
            throw new \Exception('参数为空');
        }
        $startTime = strtotime($startTime);  // 装换成时间戳
        $startTime = date('Y-m-d', $startTime); // 装换成日期时间字符串
        $openSql = House::openHomeModel('created_at', $startTime);
        return $openSql;
    }


}
